<template>
	<div>
		<div class="pub-title">后台管理</div>
		<ul class="pub-tab">
			<li class="option-list">
				<a href="article.html" class="option on">文章</a>
				<!-- <a href="article_classify.html" class="option">分类</a> -->
			</li>
			<li class="tab-block-list">
				<div class="pub-form-line">
					<div class="pub-form-line-left sign">文章标题</div>
					<div class="pub-form-line-right">
						<input type="text" class="pub-input" v-model="articleInfo.title"/>
						<input type="hidden" v-model="articleInfo._id"/>
					</div>
				</div> 
				
				<div class="pub-form-line">
					<div class="pub-form-line-left">副标题</div>
					<div class="pub-form-line-right">
						<input type="text" class="pub-input" v-model="articleInfo.describe"/>
					</div>
				</div>
				
				<div class="pub-form-line">
					<div class="pub-form-line-left sign">所属分类</div>
					<div class="pub-form-line-right">
						<select v-model="articleInfo.classify">
							<option value="1">易学文章</option>
							<option value="2">关于我们</option>
						</select>
					</div>
				</div>
				<div class="pub-form-line">
					<div class="pub-form-line-left sign">是否显示</div>
					<div class="pub-form-line-right">
						<label><input type="radio" name="isshow" value="1" v-model="articleInfo.isshow"/> 是</label>
						<label><input type="radio" name="isshow" value="0" v-model="articleInfo.isshow"/> 否</label>
					</div>
				</div>
				<div class="pub-form-line">
					<div class="pub-form-line-left sign">是否首页显示</div>
					<div class="pub-form-line-right">
						<label><input type="radio" name="isindex" value="1" v-model="articleInfo.isindex"/> 是</label>
						<label><input type="radio" name="isindex" value="0" v-model="articleInfo.isindex"/> 否</label>
					</div>
				</div>
				<div class="pub-form-line">
					<div class="pub-form-line-left sign">排序</div>
					<div class="pub-form-line-right">
						<input type="text" class="pub-input" v-model="articleInfo.sort"/>
					</div>
				</div>
				<div class="pub-form-line">
					<div class="pub-form-line-left sign">文章内容</div>
					<div class="pub-form-line-right" style="line-height: 1.5;">
						<textarea id="content" style="width:800px;height:400px;">{{articleInfo.content}}</textarea>
					</div>
				</div>					
				<div class="pub-form-line">
					<div class="pub-form-line-left"></div>
					<div class="pub-form-line-right">
						<button class="pub-btn pub-btn-bgred pub-btn-big" @click="submit">提交</button>
					</div>
				</div>
			</li>   
		</ul>		
	</div>       
</template>
 
<script>
	module.exports = { 
		data:function(){
			return {
				articleInfo:{
					classify:1,
					isshow:"1",
					isindex:"0"
				},
			}
		},
		methods:{
		    submit(){
				this.articleInfo.content=UE.getEditor('content').getContent();
				var url=this.articleInfo._id?'article/update':'article/add';
				console.log(this.articleInfo)
		        ajax({
					url:url,
					data:this.articleInfo,
					type:'post',
					success:function(res){
						if(res.state==1){
							location.href="article.html";
						}else{
							UI.alert(res.msg);
						}
					}
				})
		    }
		},		
		created(){
			_this=this;
			UE.getEditor('content');
			if(query.id){
				 ajax({
					url:"article/get",
					data:{id:query.id},
					success:function(res){
						if(res.state==1){
							_this.articleInfo=res.data;
						}else{
							UI.alert(res.msg);
						}
					}
				})
			}
		}
	}
	 
	
</script>